Repository navigation
fix(registry): respect reduced motion in WordRotate, SpinningText and SparklesText - #1111
Conversation
|
@yashjaiswal2818 is attempting to deploy a commit to the product-studio Team on Vercel. A member of the Team first needs to authorize it. |
jinho-yeom
left a comment
There was a problem hiding this comment.
Shouldn't SpinningText use <MotionConfig reducedMotion="user"> too, like WordRotate? A transition set inside variants still spins under reduced motion.
…s respect reduced motion
|
good catch, you're right. a transition inside variants overrides the one on the component, so it kept spinning. i checked in chrome with reduced motion on: default, the transition prop and a variants transition all hold still now, and nothing changes without the setting. pushed the fix, SpinningText uses MotionConfig like WordRotate. left SparklesText on useReducedMotion since it doesn't take variants or transition props. |
jinho-yeom
left a comment
There was a problem hiding this comment.
@yashjaiswal2818 Thanks for the quick fix and contribution!
Description
WordRotate, SpinningText and SparklesText animate continuously and ignore
prefers-reduced-motion. This makes all three respect it. With reduced motion on, they still show their content, just without the movement. Without it, nothing changes.Changes
<MotionConfig reducedMotion="user">. With reduced motion, motion skips the slide and keeps the opacity fade, so words still change but don't move. This also covers custommotionProps.<MotionConfig reducedMotion="user">, so the ring stays still. This covers atransitionset inside customvariantstoo (thanks @jinho-yeom for catching that).pnpm build:registryand committed the generated files.Motivation
These three loop forever and the OS setting can't stop them. Six components already respect reduced motion (DiaTextReveal, Dither, Floating3DParticles, IconCloud, RetroGrid, ScrollBasedVelocity), but these three didn't.
WordRotate uses
MotionConfiginstead ofuseReducedMotion()because the hook returnsnullon the server and the real value on the client. Changing WordRotate'sinitialfrom it caused a hydration mismatch, and the first word stayed stuck 50px up and out of view.MotionConfigapplies at animation time, so the server and client render the same markup. SpinningText usesMotionConfigfor the same reason, and because atransitioninsidevariantsoverrides one set on the component. SparklesText takes novariantsortransitionprops, so it only needsuseReducedMotion()to show still sparkles and skip its update interval.Breaking Changes
None for default setups. One edge case: if an app sets its own
<MotionConfig reducedMotion>, the inner"user"in WordRotate and SpinningText takes precedence inside those components.Screenshots
This is a motion-only change, so I checked behavior instead of static screenshots. I loaded the three docs pages in Chrome with
prefers-reduced-motionemulated on and off, and sampled the animated elements over time:There were no hydration or console errors on any of the three pages in either mode.
Checklist
pnpm checkpasses locallypnpm buildpasses locallypnpm build:registrywas run and the generated files are committed